module EventEditor
  module Route
    class AnimeDialog
      def self.show(base, &func)
       dialog = Gtk::Dialog.new("Move Wait",
               base,
               Gtk::Dialog::MODAL |
               Gtk::Dialog::DESTROY_WITH_PARENT,
               ["OK", Gtk::Dialog::RESPONSE_OK],
               ["Cancel", Gtk::Dialog::RESPONSE_CANCEL]
               )

        vbox = Gtk::VBox.new
        vbox.set_border_width(5)
          
        vbox.add(@move_anime = Gtk::CheckButton.new('anime(move)'))
        vbox.add(@stay_anime = Gtk::CheckButton.new('anime(stay)'))
        
        dialog.vbox.add(vbox)
        dialog.vbox.show_all

        # run
        dialog.run do |response|
          if response == Gtk::Dialog::RESPONSE_OK
            func.call(@move_anime.active?, @stay_anime.active?)
          else
            func.call(:cancel, :cancel)
          end
          dialog.destroy
        end
      end
    
      def self.command_to_s(args)
        t = {true => "ON", false => "OFF"}
        return "Anime: Move=#{t[args[1]]} Stay=#{t[args[2]]}"
      end
    end
  end
end